<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../../header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body style="align: center;">
	<div style="margin-top: 10px; margin-left: 30px;">
		<form id="manage-form" action="">
			<div style="margin-left: 10px;">
					<label for="jobcode">SystemCode:</label> <input type="text"
					style="width: 120px; height: 28px;" class="ui-input"
					name="systemcode" id="systemcode">
					<br>
					<label for="jobcode">SystemName:</label> <input type="text"
					style="width: 120px; height: 28px;" class="ui-input"
					name="systemname" id="systemname">
					<br>
			</div>
		</form>
	</div>

	<script type="text/javascript">
var api=frameElement.api;
var operate=api.data.operate;
var rowid=api.data.rowid;
var rowdata=api.data.rowdata;
var CallBack=api.data.callback;
$(function(){
	initPopBtns();
	if(operate=="edit"){
		$("#systemcode").val(rowdata.systemcode);
		$("#systemname").val(rowdata.systemname);
	}
})
function initPopBtns() {
	var btnname = "add" == operate ? ["保存", "关闭"] : ["确定", "取消"];
	api.button({
		id: "confirm",
		name: btnname[0],
		focus: true,
		callback: function(e) {
			var systemCode=$("#SystemCode").val();
			var systemName=$("#SystemName").val();
			if(operate=="add"){
				$.ajax({
					url : 'systemController/editSystem',
					type : 'POST',
					dataType : "json",
					data: {
						"systemcode":systemCode,
						"systemname":systemName,
						"oper":"add"
					},
					async : false,
					success : function(map) {
						if(map.status==200){
							parent.Public.tips({
								content: "添加参数类别成功"
							})
							CallBack();
						}else{
							parent.Public.tips({
								type:1,
								content: "添加参数类别失败:"+data.msg
							})
						}
					}
				});
			}else{
				$.ajax({
					url:encodeURI("systemController/editSystem"),
					type:"POST",
					data:{
						"id":rowid,
						"systemcode":systemCode,
						"systemname":systemName,
						"oper":"edit"
					},
					async : false,//同步,坑爹啊。。
					success:function(data){
						if(data.status==1){
							parent.Public.tips({
								content: "修改商品类别成功"
							})
							CallBack();
						}else{
							parent.Public.tips({
								type:1,
								content: "修改商品类别失败:"+data.msg
							})
						}		
					}
				});
			}
		}
	}, {
		id: "cancel",
		name: btnname[1]
	})
}



</script>
</body>
</html>